package com.yax.mickey.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yax.mickey.entity.Product;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author yax
* @description 针对表【product(商品信息表)】的数据库操作Mapper
* @createDate 2024-05-27 09:02:22
* @Entity com.yax.mickey.entity.Product
*/
@Mapper
public interface ProductMapper extends BaseMapper<Product> {
    @Select("select * from product")
    List<Product> getAllProducts();

    @Select("select * from product where product_id = #{productId}")
    Product getProductById(Integer productId);

    @Select("select * from product where category_id = #{categoryId}")
    List<Product> getProductByCategoryId(Integer categoryId);

    @Select("SELECT * FROM product WHERE product_name LIKE CONCAT('%', #{productName}, '%')")
    List<Product> getProductBySearch(@Param("productName") String productName);

}




